var table;
layui.use('table', function(){
    table = layui.table
        ,form = layui.form;
    table.render({
        elem: '#test1'
        ,url:'/adminListData'
        ,cellMinWidth: 80
        ,cols: [[
            {field:'adminId', title:'编号'}
            ,{field:'adminName', title:'用户名'}
            ,{field:'realName', title:'真实姓名'}
            ,{field:'limited', title: '权限'}
            ,{field:'rankid', title:'编辑', minWidth:180, templet: '#barDemo', unresize: true}
        ]]
        ,page: true
        ,limit:10
    });
});

function WinOpenAdd() {
    layer.open({
        type: 2
        , title: '添加后台管理员'
        , content: '/addAdmin'
        , area: ['520px', '520px']
        , btn: ['确定', '取消']
        // , yes: function (addAdmin, layero) {
            //debugger;
            // var body = layer.getChildFrame('body', addAdmin); //得到iframe页的body内容
            // var loginname = body.find("#username").val();
            // alert(loginname);
            //table.reload('LAY-user-front-submit'); //数据刷新
            //layer.close(index); //关闭弹层
        // }

    });

}
//查看
function WinOpenEdit(adminId){
    alert("edit------>"+adminId);
}

//编辑
function  WinOpenEditAdmin(adminId) {
    layer.open({
        type: 2
        , title: '编辑后台管理员'
        , content: '/editAdmin?adminId='+adminId
        , area: ['520px', '520px']
        , btn: ['确定', '取消']
    });


    var $ = layui.$, active = {
        reload: function(){
            var demoReload = $('#demoReload');

            //执行重载
            table.reload('testReload', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                ,where: {
                    key: {
                        id: demoReload.val()
                    }
                }
            });
        }
    };

    $('.demoTable .layui-btn').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });

}

//删除
function WinOpenDelAdmin(adminId){
    alert("您确定要删除"+adminId+"号管理员吗？");
    $.ajax({
        url:"/delAdmin?adminId="+adminId
    })


}




